Install tomcat9

  • Steps

    Step 1: Update Package Lists

    
                     sudo apt update
    

    Step 2: Install Tomcat

    
    sudo apt install tomcat9
    

    Step 3: Verify Tomcat Installation

    
    sudo systemctl status tomcat9
    
    

    Step 4: Access Tomcat

    
    sudo ufw allow 8080/tcp
    
    sudo ufw reload
    

    open browser and call http://localhost:8080

    4. start, stop, or restart Tomcat

    
    Start Tomcat:    sudo systemctl start tomcat9
    
    Stop Tomcat:     sudo systemctl stop tomcat9
    
    Restart Tomcat:  sudo systemctl restart tomcat9
    
    common locations where you might find the Tomcat 9 service file:

    /etc/systemd/system/tomcat9.service

    /lib/systemd/system/tomcat9.service

    /etc/init.d/tomcat9

    
    
    1. Create service files in /lib/systemd/system
    
    ptv-xcluster.service
    ptv-xdima.service
    ptv-xlocate.service 
    ptv-xroute.service  
    ptv-xserver.service 
    ptv-xterritory.service  
    ptv-xtour.service 
    
    2. Update  /lib/systemd/system/ptv-xserver.service
    
    [Unit]
    Description=PTV xserver2 service
    After=network.target
    
    
    [Service]
    
    # Configuration
    #Environment=JAVA_HOME=/usr/jdk/amazon-corretto-17.0.9.8.1-linux-x64
    #Environment=CATALINA_PID=/opt/xServerLinux/xserver-2.31.0/pid
    #Environment=CATALINA_HOME=/opt/xServerLinux/xserver-2.31.0
    #Environment=CATALINA_BASE=/opt/xServerLinux/xserver-2.31.0
    #Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
    
    
    # Lifecycle
    
    ExecStart=/opt/xServerLinux/xserver-2.31.0/xserver.sh console
    #ExecStop=/opt/xServerLinux/xserver-2.31.0/xserver.sh stop
    #SuccessExitStatus=143
    #Restart=on-abort
    
    
    
    # Security
    User=root
    Group=root
    
    
    
    [Install]
    WantedBy=multi-user.target
    
    
    3. Update  /lib/systemd/system/ptv-xcluster.service
    
    [Unit]
    Description=PTV xcluster service
    After=network.target
    
    
    [Service]
    
    # Configuration
    #Environment=JAVA_HOME=/usr/jdk/amazon-corretto-17.0.9.8.1-linux-x64
    #Environment=CATALINA_PID=/opt/xServerLinux/xserver-2.31.0/pid
    #Environment=CATALINA_HOME=/opt/xServerLinux/xserver-2.31.0
    #Environment=CATALINA_BASE=/opt/xServerLinux/xserver-2.31.0
    #Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
    
    
    # Lifecycle
    
    ExecStart=/opt/xServerLinux/xcluster-x64-1.38.0.1/xcluster.sh console
    #ExecStop=/opt/xServerLinux/xserver-2.31.0/xserver.sh stop
    #SuccessExitStatus=143
    #Restart=on-abort
    
    
    
    # Security
    User=root
    Group=root
    
    
    
    [Install]
    WantedBy=multi-user.target
    
    4. Update  other service files with corresponding .sh file path
    
    
    
    
    
    
    
    
    
    
    6..  Run the service files                                                                                                        .                                                               
    
    1. Enable
    
    sudo systemctl enable ptv-xcluster.service
    
    sudo systemctl enable ptv-xdima.service
    
    sudo systemctl enable ptv-xlocate.service
    
    sudo systemctl enable ptv-xroute.service
    
    sudo systemctl enable ptv-xserver.service
    
    sudo systemctl enable ptv-xterritory.service
    
    sudo systemctl enable ptv-xtour.service
    
    2. Run
    sudo systemctl start ptv-xcluster.service
    
    sudo systemctl start ptv-xdima.service
    
    sudo systemctl start ptv-xlocate.service
    
    sudo systemctl start ptv-xroute.service
    
    sudo systemctl start ptv-xserver.service
    
    sudo systemctl start ptv-xterritory.service
    
    sudo systemctl start ptv-xtour.service
    
    
    3. Restart
    sudo systemctl restart ptv-xcluster.service
    
    sudo systemctl restart ptv-xdima.service
    
    sudo systemctl restart ptv-xlocate.service
    
    sudo systemctl restart ptv-xroute.service
    
    sudo systemctl restart ptv-xserver.service
    
    sudo systemctl restart ptv-xterritory.service
    
    sudo systemctl restart  ptv-xtour.service
    
    
    4. stop
    sudo systemctl stop ptv-xcluster.service
    
    sudo systemctl stop ptv-xdima.service
    
    sudo systemctl stop ptv-xlocate.service
    
    sudo systemctl stop ptv-xroute.service
    
    sudo systemctl stop ptv-xserver.service
    
    sudo systemctl stop ptv-xterritory.service
    
    sudo systemctl stop  ptv-xtour.service